/**
 * FileName: RequestMessage
 * Author:   powersi
 * Date:     2021/2/26 10:40
 * Description:
 */
package com.zm.demo.netty.action.common;

/**
 * Description: 
 * Author:      powersi
 * Date:        2021/2/26 10:40
 */
public class RequestMessage extends Message<Operation> {
    public RequestMessage() {
    }

    public RequestMessage(Long streamId, Operation operation) {
        MessageHeader messageHeader = new MessageHeader();
        messageHeader.setReqId(streamId);
        messageHeader.setReqType(OperationType.fromOperation(operation).getOpCode());
        this.setMessageHeader(messageHeader);
        this.setMessageBody(operation);
    }

    @Override
    public Class getMessageBodyClass(int reqType) {
        return OperationType.fromOpCode(reqType).getOperationClazz();
    }
}
